// JavaScript Document
$(document).ready(
	function(){
		var fenleiTimeout=0;
		$('.parentLiDiv a').mouseover(
			function(){
				var child=$(this).parent().next();
				fenleiTimeout=setTimeout(function(){
								$('.childMenu').slideUp('slow');
								if(child.size()>0){
									child.slideDown();
								}
							},500);
			}
		);
		$('.parentLiDiv a').mouseout(
			function(){
				clearTimeout(fenleiTimeout);
			}
		);
	}
)

var myFavorite={
	checkUser:function(){
		var member_type=getCookie(COOKIE_PRE+"member_type");
		if(member_type==''){
			if(confirm("Please login first.")){
				window.location.href=ROOT_PATH+'/auth-login';	
			}
			return false;
		}else if(member_type!='buyer'){
			alert('Your are not a buyer!');
			return false;
		}
		return true;
	},
	addItemFavor:function(itemid){
		if(this.checkUser()){
			GGSHOP.loading.show();
			$.post(ROOT_PATH+"/adminb-favor-doadditem",{itemid:itemid},function(data) {
				if(trim(data)=='success'){
					GGSHOP.loading.hidden();
					GGSHOP.msgBox.show('message', 'Excellent!');
				}else{
					GGSHOP.loading.hidden();
					GGSHOP.msgBox.show('error','You have added this item to your wish list.');		
				}
			});	
		}
	},
	addCateFavor:function(flid){
		if(this.checkUser()){
			GGSHOP.loading.show();
			$.post(ROOT_PATH+"/adminb-favor-doaddcate",{flid:flid},function(data) {
				if(trim(data)=='success'){
					GGSHOP.loading.hidden();
					GGSHOP.msgBox.show('message', 'Excellent!');	
				}else{
					GGSHOP.loading.hidden();
					GGSHOP.msgBox.show('hidden', 'You have added this Catalog to your favorite Catalogs!');		
				}
			});
		}
	}
}
